<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>零售发货</title>
	<link rel="shortcut icon" href="https://gtms04.alicdn.com/tps/i4/TB1_oz6GVXXXXaFXpXXJDFnIXXX-64-64.ico" type="image/x-icon"/>
	<link rel="stylesheet" href="https://g.alicdn.com/thx/cube/1.3.2/cube.min.css">
	<link rel="stylesheet" href="/wjfh/css/iconfont.css">
	<link rel="stylesheet" type="text/css" href="/wjfh/css/common.css"/>
	<link rel="stylesheet" type="text/css" href="/wjfh/layui/css/layui.css"/>
	<link rel="stylesheet" type="text/css" href="/wjfh/css/style.css"/>
	<script src="/wjfh/js/flexible.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div class="" id="fahuo" v-cloak>
	<div class="resgcontain layui-form">
		<h1 class="site-h1">我要发货-零售发货</h1>
		<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
			<ul class="layui-tab-title">
				<li class="layui-this"><a href="/goodsManager/page/retail">零售发货</a></li>
				<li><a href="/goodsManager/page/ddgl">代理订单</a></li>
			</ul>
			<div class="item"></div>
			<div class="item">
				<div class="saomaiptbox">
					<input type="text" class="publicIptSty widthman"  value="" placeholder="商品二维码" readonly="readonly"/>
					<span class="icon iconfont" @click="openwxSaoma()">&#xe68c;</span>
				</div>
			</div>
			<div class="item">
				<textarea class="publicIptSty widthman" id="erwemaarrval" placeholder="二维码" v-model="tiaoxingma"></textarea>
			</div>
		</div>
	</div>
	<div class="shangpd">
		<button class="layui-btn layui-btn-fluid resgSubmit" @click="fahuofun();">确认出货</button>
	</div>
</div>

	<script src="/wjfh/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<script src="/wjfh/js/vue.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="/wjfh/js/axios.js" type="text/javascript" charset="utf-8"></script>
	<script src="/js/jquery.min.js?v=2.1.4" th:src="@{/js/jquery.min.js?v=2.1.4}"></script>
<script src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
	<script>
        var idata = new  Vue({
            el:"#fahuo",
            data:{
				tiaoxingma:'',
                textval:''
            },
            methods:{
                fahuofun:function () {
                    if(idata.tiaoxingma !=''){
                        $.ajax({
                            cache: true,
                            type: "POST",
                            data:{
                                ids:idata.tiaoxingma,
                            },
                            url: "/goodsManager/retail/toRetail",
                            error : function(request) {
                                layer.alert("Connection error");
                            },
                            success : function(data) {
                                if(data.code != 500){
                                    layer.msg('出货成功!', {icon: 6,time: 1200},function () {
                                        parent.location.href = '/goodsManager/page/index';
                                    });
                                }else{
                                    layer.msg(data.msg, {icon: 5,time: 1200},function () {
                                        //parent.location.href = '/goodsManager/page/index';
                                    });
                                }
                            }
                        });

                    }else{
                        layer.msg('请先扫码出货！', {icon: 5,time: 1200});
                    }

                },
                openwxSaoma:function () {

                    wx.ready(function () {
                        wx.scanQRCode({
                            needResult: 1,
//                    		desc: 'scanQRCode desc',
                            scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有　　
                            success: function (res) {
                                var serialNumber = res.resultStr;
                                if(serialNumber.indexOf(',') > 0){
                                    var dealserialNumber=serialNumber.split(',')[1];
                                    dealserialNumber = dealserialNumber.replace(/[^a-z\d]/ig, "");

                                    idata.textval+=dealserialNumber+',';
                                    $("#erwemaarrval").val(idata.textval.substring(0, idata.textval.lastIndexOf(',')));
									idata.tiaoxingma = idata.textval.substring(0, idata.textval.lastIndexOf(','));
                                }else{

                                }
                            }
                        });

                    });
                }
            },
            mounted:function () {

                layui.use(['jquery', 'form','layer'], function() {
                    $ = layui.jquery,
                        form = layui.form,
                        layer = layui.layer;
                    var link = location.href.split('#')[0];
                    $.ajax({
                        //cache: false,
                        type: "GET",
                        data:{"url":link},
                        url: "/wechat/wechatParam",
                        error : function(request) {
                            layer.alert("Connection error");
                        },
                        success : function(data) {
                            console.log(data);
                            wx.config({
                                debug: false,
                                appId: data.appid,
                                timestamp: data.timestamp,
                                nonceStr: data.nonceStr,
                                signature: data.signature,
                                jsApiList: [
                                    'checkJsApi',
                                    'onMenuShareTimeline',
                                    'onMenuShareAppMessage',
                                    'onMenuShareQQ',
                                    'onMenuShareWeibo',
                                    'hideMenuItems',
                                    'showMenuItems',
                                    'hideAllNonBaseMenuItem',
                                    'showAllNonBaseMenuItem',
                                    'translateVoice',
                                    'startRecord',
                                    'stopRecord',
                                    'onRecordEnd',
                                    'playVoice',
                                    'pauseVoice',
                                    'stopVoice',
                                    'uploadVoice',
                                    'downloadVoice',
                                    'chooseImage',
                                    'previewImage',
                                    'uploadImage',
                                    'downloadImage',
                                    'getNetworkType',
                                    'openLocation',
                                    'getLocation',
                                    'hideOptionMenu',
                                    'showOptionMenu',
                                    'closeWindow',
                                    'scanQRCode',
                                    'chooseWXPay',
                                    'openProductSpecificView',
                                    'addCard',
                                    'chooseCard',
                                    'openCard'
                                ]

                            });
                        }
                    });

                })
            }
        })
	</script>
</body>
</html>
